package com.dogdog.bean;

import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;

import com.android.volley.Response;
import com.android.volley.Response.ErrorListener;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageRequest;
import com.dogdog.manager.C;
import com.dogdog.manager.MyApplication;
import com.google.gson.annotations.SerializedName;

public class Me extends Status{
 	
	//这里是Login接口返回的result数据
	@SerializedName("user_id")
	int id;
    @SerializedName("user_name")
	String name;
	@SerializedName("user_sex")
	int sex;
	@SerializedName("user_hadpet")
	int hadpet;
	@SerializedName("user_face")
	String user_face;
	@SerializedName("user_email")
	String email;
	
	Bitmap faceBitmap;
	public int getID(){
		return id;
	}
	public String getName() {
		return name;
	}
	public int getSex() {
		return sex;
	}
	public int getHadpet() {
		return hadpet;
	}
	public String getEmail(){
		return email;
	}
	
	public String getUser_face() {
		return user_face;
	}
	
	
	
	public void setName(String name) {
		this.name = name;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	//调用的时候就通过网络获取位图
	public Bitmap getFaceBitmap(){
		if(faceBitmap==null){
		ImageRequest bit=new ImageRequest(
				C.URL.FACE_PATH+user_face, 
				new Response.Listener<Bitmap>() {
					@Override
					public void onResponse(Bitmap bitmap) {
				    faceBitmap=bitmap;		
					}
				},
				 0, 0, Config.ARGB_8888, new ErrorListener() {
					@Override
					public void onErrorResponse(VolleyError error){
					faceBitmap=MyApplication.getUnkowBit();	
					}
				}){
		};
	MyApplication.getHttpQueue().add(bit);	
		}
		return faceBitmap;
	}
	
	@Override
	public String toString() {
		return "name="+name+",sex="+sex+"hadpet"+hadpet;
	}
}
